CEOI 1996, Slovacia, octombrie
CONTAINERE (40 puncte)

	Un robot ia obiecte de pe o banda de asamblare, in ordinea in care
acestea sunt produse si le introduce in containere. La fiecare moment de timp 
sunt deschise exact doua containere. Greutatea maxima de incarcare este aceeasi
pentru toate containerele.
Daca inchidem un container, el nu va mai putea fi ulterior deschis. 
Robotul realizeaza in fiecare unitate de timp una din urmatoarele actiuni:
1. Introduce un obiect in containerul 1.
2. Introduce un obiect in containerul 2.
3. Inchide containerul 1 si deschide un nou container gol in locul lui.
4. Inchide containerul 2 si deschide un nou container gol in locul lui.
	Evident, un obiect poate fi introdus intr-un container numai daca nu 
s-a depasit greutatea maxima.
	Greutatile obiectelor de pe banda sunt date in ordinea in care apar.
Sa se determine numarul minim de containere necesare.

Intrare:
	Fisierul de intrare contine numai numere intregi. Pe prima linie se
afla un singur numar acre reprezinta greutatea maxima L (1<=L<=100), care poate
fi stocata intr-un container.
Linia a doua contine numarul N (1<=N<=5000) de obiecte ce trebuie stocate. 
Pe urmatoarele N linii apar greutatile obiectelor; fiecare greutate este un
numar din intervalul [1,L].

Iesirea:
	Se scrie in prima linie a fisierului de iesire numarul minim de
containere necesare.

Exemplu:
BINPACK.IN					BINPACK.OUT
8							3
6							
4
2
5
3
5
4
====================================
Solutie:
program binpack;
uses crt;
type sir=array[0..100] of boolean;
     sir1=array[0..100] of integer;
var a:array[1..5000] of shortint;
    l,n:integer;
    s,tmps:sir;
    c,b,tmpc,tmpb:sir1;
    min,k,i,an,bn,cn:integer;

procedure citire;
 var f:text;
     nume:string;
     i:integer;
 begin
  clrscr;
  write('Introduceti numele fisierului de intrare : ');
  readln(nume);
  assign(f,nume);
  reset(f);
  readln(f,l);
  readln(f,n);
  for i:=1 to n do
   readln(f,a[i]);
  close(f);
 end;

begin
 citire;
 for i:=0 to l do
  begin
   s[i]:=false;
   b[i]:=0;
   c[i]:=0;
  end;
 s[0]:=true;
 for k:=1 to n do
  begin
   for i:=0 to l do
    begin
     tmps[i]:=false;
     tmpb[i]:=0;
     tmpc[i]:=0;
    end;
   for i:=0 to l do
    if s[i] then begin
                  if a[k]+i>l then begin
                                    cn:=c[i]+1;
                                    an:=a[k];
                                    bn:=b[i];
                                   end
                              else begin
                                    cn:=c[i];
                                    an:=a[k]+i;
                                    bn:=b[i];
                                   end;
                  if not(tmps[an]) or (tmps[an] and
                     ((cn<tmpc[an]) or ((cn=tmpc[an]) and  (bn<tmpb[an]))))
                      then begin
                            tmps[an]:=true;
                            tmpc[an]:=cn;
                            tmpb[an]:=bn;
                           end;
                  if a[k]+b[i]>l then begin
                                       cn:=c[i]+1;
                                       an:=i;
                                       bn:=a[k];
                                      end
                                 else begin
                                       cn:=c[i];
                                       an:=i;
                                       bn:=b[i]+a[k];
                                      end;
                  if not(tmps[an]) or (tmps[an] and
                     ((cn<tmpc[an]) or ((cn=tmpc[an]) and  (bn<tmpb[an]))))
                      then begin
                            tmps[an]:=true;
                            tmpc[an]:=cn;
                            tmpb[an]:=bn;
                           end;

                 end;
   c:=tmpc;
   b:=tmpb;
   s:=tmps;
  end;
 min:=maxint;
 for i:=1 to l do
  if s[i] then
  if b[i]>0 then begin if c[i]+2<min then min:=c[i]+2; end
            else if c[i]+1<min then min:=c[i]+1;
  if s[0] then
 if b[0]>0 then begin if c[0]+1<min then min:=c[0]+1; end
           else if c[0]<min then min:=c[0];
 writeln(min);
end.
-------------------------------
Solutie 1 (Bogdan Batog)
var
   fil                                  :text;
   n,l,f,i,j,g                          :integer;
   s1,s2                                :array[0..100,0..100] of integer;

begin
     assign(fil,'binpack.in');
     reset(fil);
     readln(fil,L);
     readln(fil,N);
     for i:=0 to L do
      for j:=0 to L do s1[i,j]:=maxint;
     s2:=s1;
     s1[0,0]:=0;
     for f:=1 to n do
     begin
          readln(fil,g);
          for i:=0 to L do
           for j:=0 to L do
           if s1[i,j]<>maxint then
           begin
                if i+g<=l then
                begin
                     if s2[i+g,j]>s1[i,j] then s2[i+g,j]:=s1[i,j]
                end else
                 if s2[g,j]>1+s1[i,j] then s2[g,j]:=1+s1[i,j];

                if j+g<=l then
                begin
                     if s1[i,j+g]>s1[i,j] then s2[i,j+g]:=s1[i,j]
                end else
                 if s2[i,g]>1+s1[i,j] then s2[i,g]:=1+s1[i,j];
           end;
          s1:=s2;
          for i:=0 to l do
           for j:=0 to l do s2[i,j]:=maxint;
     end;
     close(fil);
     f:=maxint;
     for i:=0 to l do
      for j:=0 to l do
      if s1[i,j]<>maxint then
      begin
       if i<>0 then inc(s1[i,j]);
       if j<>0 then inc(s1[i,j]);
       if (s1[i,j]<f) and (s1[i,j]<>maxint) then f:=s1[i,j];
      end;
     writeln(f);
end.
---------------------------
Solutie 2 (Cristian cadar)
uses crt;
type
    sir=array[0..100] of byte;
var
   t,x,a,b:sir;
   ob1,ob2,aux,s1p,s2p,suma,ob,s1,s2,nr,l,n,i,j,k:integer;
   st:string;
   f:text;
   da,gasit:boolean;

procedure citire;
begin
     clrscr;
     write('Fisier intrare:');
     readln(st);
     assign(f,st);
     reset(f);
     readln(f,l);
     readln(f,n);
     for i:=1 to n do
         readln(f,x[i]);
     x[n+1]:=2*l+1;
     close(f);
end;

procedure rec(k:byte);
var
   i:byte;
begin
     if k=0
        then exit
        else
            begin
                 for i:=ob1 to ob2 do
                     if x[i]=k-t[k]
                        then
                            begin
                                 x[i]:=0;
                                 break;
                            end;
                 rec(t[k]);
            end;
end;

procedure dinamic;
begin
     fillchar(a,sizeof(a),0);
     a[0]:=1;
     for i:=ob1 to ob2 do
         begin
              b:=a;
              for j:=0 to l do
                  if a[j]=1
                     then
                         begin
                              b[x[i]+j]:=1;
                              t[x[i]+j]:=j;
                         end;
              a:=b;
         end;
     s1p:=s1;s2p:=s2;
     while a[s1p]<>1 do
        dec(s1p);
     while a[s2p]<>1 do
        dec(s2p);
     da:=false;
     if s1p=0
        then
            begin
                 s1:=l;
                 da:=true;
            end;
     if s2p=0
        then
            begin
                 s2:=l;
                 da:=true;
            end;
     if da
        then
            begin
                 s1p:=s1;s2p:=s2;
                 while a[s1p]<>1 do
                    dec(s1p);
                 while a[s2p]<>1 do
                    dec(s2p);
            end;
     if (s1-s1p) < (s2-s2p)
        then
            begin
                 if s1p=l
                    then inc(nr);
                 rec(s1p);
                 fillchar(a,sizeof(a),0);
                 a[0]:=1;
                 for i:=ob1 to ob2 do
                     for j:=0 to l do
                         begin
                              b:=a;
                              if a[j]=1
                                 then
                                     begin
                                          b[x[i]+j]:=1;
                                          t[x[i]+j]:=j;
                                     end;
                              a:=b;
                         end;
                 s2p:=s2;
                 while a[s2p]<>1 do
                   dec(s2p);
                 if s2p=l
                    then inc(nr);
                 if s2p<>0
                    then rec(s2p);
            end
        else
            begin
                 if s2p=l
                    then inc(nr);
                 rec(s2p);
                 fillchar(a,sizeof(a),0);
                 a[0]:=1;
                 for i:=ob1 to ob2 do
                     for j:=0 to l do
                         begin
                              b:=a;
                              if a[j]=1
                                 then
                                     begin
                                          b[x[i]+j]:=1;
                                          t[x[i]+j]:=j;
                                     end;
                              a:=b;
                         end;
                 s1p:=s1;
                 while a[s1p]<>1 do
                     dec(s1p);
                 if s2p=l
                    then inc(nr);
                 if s2p<>0
                    then rec(s2p);
            end;

end;

procedure generare;
begin
     nr:=0;             { Nr. de silozuri deschise }
     s1:=l;s2:=l;   { Capacitatile din cele 2 silozuri }
     ob1:=1;ob2:=0; { Limitele secventei selectate - a crei sum nu depseste 2*l }
     while ob2<n do
       begin
            suma:=0;
            while suma<2*l do
              begin
                   inc(ob2);
                   suma:=suma+x[ob2];
              end;
            dec(ob2);
            dinamic;
            ob1:=ob2+1;
       end;
end;

begin
     citire;
     generare;
end.
------------------------------
Solutie 3 (Alin Simpalean)
program Bin_Pack;
  var l:byte;
      n:word;
      m:packed array[1..5000] of byte;
      c1,c2:packed array[0..99,0..99] of word;
  procedure Citire;
    var f:text;
        i:word;
    begin
      assign(f,'binpack.in');
      reset(f);
      readln(f,l);
      readln(f,n);
      for i:=1 to n do
        readln(f,m[i]);
      close(f)
    end;
  procedure Rezolvare;
    var j,k:byte;
        i,nc,cc:word;
    begin
      fillchar(c2,sizeof(c2),255);
      c2[0,0]:=0;
      for i:=1 to n do
        begin
          c1:=c2;
          fillchar(c2,sizeof(c2),255);
          for j:=0 to l-1 do
            for k:=0 to l-1 do
              begin
                if (c1[j,k]<>65535) then
                  begin
                    nc:=c1[j,k]+(j+m[i]) div l;
                    if (nc<>c1[j,k]) and (j+m[i]<>l) then cc:=m[i]
                                                     else cc:=(j+m[i]) mod l;
                    if c2[cc,k]>nc then c2[cc,k]:=nc;
                    nc:=c1[j,k]+(k+m[i]) div l;
                    if (nc<>c1[j,k]) and (k+m[i]<>l) then cc:=m[i]
                                                     else cc:=(k+m[i]) mod l;
                    if c2[j,cc]>nc then c2[j,cc]:=nc
                  end;
              end;
          for j:=0 to l-1 do
            begin
              for k:=0 to l-1 do
                write(c2[j,k]:7);
              writeln
            end;
          readln;
        end;
    end;
  procedure Tiparire;
    var f:text;
        i,j:byte;
        m,ll:longint;
    begin
      assign(f,'binpack.out');
      rewrite(f);
      m:=65535;
      for i:=0 to l-1 do
        for j:=0 to l-1 do
          begin
            ll:=c2[i,j];
            ll:=ll+(i+99) div 100+(j+99) div 100;
            if ll<m then m:=ll
          end;
      writeln(f,m);
      close(f)
    end;
  begin
    Citire;
    Rezolvare;
    Tiparire
  end.
====================================
Test 0
Intrare:
8
6
4
2
5
3
5
4
Iesire
3
-------------------
test 1
Intrare
5
100
4
5
4
2
3
3
1
1
3
1
3
4
2
4
2
5
5
4
2
2
3
5
5
2
5
5
3
1
5
2
1
2
3
1
4
2
5
3
3
3
4
4
4
4
4
5
4
4
5
5
4
2
1
3
4
5
5
4
4
4
5
2
2
1
5
2
2
1
4
3
2
1
1
2
4
3
3
1
2
2
3
3
4
1
4
5
1
3
4
1
1
4
2
4
3
4
2
1
5
1
Iesire:
67
---------------------
test 2
Intrare:
10
100
2
9
9
5
9
7
4
10
7
3
3
1
2
3
2
3
4
3
6
8
8
7
5
6
4
9
2
4
10
4
6
4
2
9
6
4
9
6
6
8
2
4
2
8
6
10
6
10
2
6
6
5
4
4
2
2
7
3
4
5
2
5
2
8
9
6
10
6
9
7
8
2
3
5
1
4
8
5
7
2
8
5
5
10
7
5
3
6
3
2
7
1
4
9
8
7
1
6
8
5
Iesire:
60
--------------------
Test 3
Intrare:
20
200
3
13
3
10
16
19
7
19
12
4
9
9
10
3
6
3
5
15
7
18
12
2
15
8
8
12
16
4
18
4
5
18
2
12
7
5
20
19
17
4
17
9
20
19
4
5
5
6
20
3
15
10
19
13
19
9
5
17
10
7
5
1
15
1
8
18
15
5
18
17
15
20
19
9
11
16
1
3
6
3
18
19
9
20
14
9
19
8
9
6
10
14
8
13
7
15
1
6
7
8
13
4
12
3
4
5
9
12
18
16
5
17
8
17
19
5
5
6
14
2
9
14
9
9
2
17
3
2
6
17
18
17
7
7
8
7
9
11
4
15
2
12
19
3
1
15
11
4
18
18
13
12
5
11
4
14
15
3
2
15
12
18
12
20
3
1
9
5
11
2
9
7
9
12
19
2
15
1
2
1
3
5
11
15
16
2
13
1
3
14
1
16
16
4
8
6
4
18
12
10
Iesire:
111
--------------------
Test 4:
Intrare:
30
300
30
10
28
7
9
14
24
6
20
8
3
6
11
6
21
12
22
15
29
28
21
3
21
21
25
23
26
19
21
20
27
21
3
18
20
25
16
13
29
17
6
12
21
9
30
26
18
12
15
23
12
14
8
21
22
15
2
29
9
26
25
6
28
11
26
30
20
12
16
7
22
18
2
23
20
5
14
11
9
15
9
21
9
13
6
7
19
19
2
16
14
8
24
11
19
30
5
16
4
24
5
8
11
6
5
29
14
24
8
26
2
13
30
28
6
11
13
5
23
29
18
14
28
3
25
5
8
30
16
29
12
21
27
15
27
23
22
27
5
12
26
21
23
24
12
27
23
13
12
13
14
26
25
4
24
30
5
21
17
25
10
28
30
10
19
12
11
4
7
25
13
13
23
4
14
9
29
26
25
17
1
19
28
4
3
5
26
22
1
3
18
24
22
26
16
23
24
3
18
16
13
12
19
15
15
20
23
14
27
30
10
11
23
27
6
1
1
19
15
7
23
17
27
6
16
3
23
21
11
8
12
21
10
15
24
13
16
24
17
25
8
7
10
6
17
29
7
6
15
26
25
23
17
13
9
9
13
20
19
17
25
5
13
25
7
12
15
9
14
4
6
26
25
9
2
1
29
3
28
26
21
15
16
20
24
1
3
9
24
16
5
15
5
19
7
17
18
20
2
8
Iesire:
182
-----------------
Test 5:
Intrare:
40
400
34
12
14
2
5
34
37
25
36
7
40
23
1
21
39
20
29
34
37
16
35
20
21
11
35
4
10
39
13
9
15
34
9
2
5
29
18
11
17
16
37
26
3
18
7
11
3
4
29
16
34
26
22
4
3
18
40
21
34
23
17
11
39
25
8
9
3
9
37
33
8
19
3
22
29
39
4
17
21
18
5
13
12
6
22
32
12
11
3
19
8
17
10
16
4
20
16
29
40
35
14
24
2
28
35
21
14
5
1
37
22
30
12
12
4
37
14
32
31
27
6
5
17
36
17
20
22
19
17
21
10
37
15
21
36
24
16
28
10
13
17
4
3
15
24
4
19
37
7
9
11
12
32
8
22
37
32
32
32
33
36
28
18
22
13
12
32
16
9
36
25
18
3
22
25
39
19
23
1
4
3
37
28
18
4
40
19
35
20
33
40
40
20
14
26
36
14
22
1
3
17
17
22
33
39
11
16
13
11
25
31
13
31
27
3
9
26
15
39
21
38
19
35
27
36
28
12
4
15
24
35
11
25
8
2
9
17
22
10
17
18
11
3
17
33
1
23
13
23
34
29
6
32
38
32
28
30
3
10
8
3
30
35
13
39
29
39
36
38
40
24
21
18
24
31
7
21
14
20
10
21
16
12
18
40
30
35
5
31
33
29
9
34
39
25
12
3
4
3
21
15
22
23
40
28
31
39
14
38
35
13
4
25
26
5
24
28
31
30
9
28
15
14
4
37
9
38
37
4
39
1
10
31
20
38
20
29
1
11
24
38
26
26
31
21
34
24
9
17
8
29
19
9
11
5
32
11
6
30
27
29
23
14
27
21
18
2
34
39
26
25
24
4
22
8
33
18
28
37
14
35
22
31
23
4
6
17
6
24
13
2
29
6
28
20
33
8
12
39
2
Iesire:
228
----------------------
Test 6:
Intrare:
50
500
48
3
19
47
39
13
43
25
2
30
13
28
1
32
25
18
5
32
4
50
21
5
4
47
1
38
40
11
34
17
18
17
10
36
13
7
5
16
32
39
28
24
30
40
8
34
8
46
50
26
12
6
50
34
9
44
31
36
22
40
6
8
26
8
11
10
19
38
49
4
35
17
35
40
43
24
40
8
30
28
29
32
25
12
19
4
41
41
33
6
28
49
46
33
21
7
30
6
14
11
3
36
17
28
36
35
43
27
36
45
19
37
34
46
40
2
16
7
31
36
19
4
7
32
39
5
32
6
45
8
43
47
39
13
1
24
18
41
13
13
50
4
31
9
4
18
26
9
20
27
17
14
28
15
3
2
30
1
21
7
34
7
21
14
17
27
15
46
46
20
34
23
48
8
9
38
33
50
19
11
48
39
45
43
23
4
5
50
31
18
31
22
27
46
32
28
35
12
45
17
8
12
28
19
9
48
22
28
13
1
25
36
3
11
15
29
45
14
48
35
14
16
38
24
5
20
31
3
28
43
35
47
21
39
15
35
25
31
27
44
37
33
23
8
29
49
38
9
10
16
8
42
16
23
1
45
50
32
40
49
22
35
34
29
24
49
6
29
3
31
9
13
50
10
6
1
8
4
30
9
7
10
9
27
39
34
8
27
44
37
2
26
28
46
50
45
35
19
9
32
12
38
36
18
46
2
40
34
7
17
13
39
6
28
17
18
44
9
32
25
20
42
31
40
49
26
47
8
46
6
26
45
34
8
9
6
23
31
10
25
36
20
18
42
48
26
43
17
9
25
26
50
11
11
8
44
23
15
47
18
26
46
3
44
16
13
10
32
26
27
21
39
39
36
33
1
3
44
45
49
23
25
26
25
2
10
35
42
29
45
26
10
18
3
31
28
15
44
3
11
3
18
46
40
2
31
50
28
15
46
22
10
40
20
1
35
28
10
33
32
31
39
22
5
44
20
46
16
6
5
36
20
2
40
28
38
47
10
23
25
4
29
21
20
27
35
50
23
26
36
42
11
35
12
25
9
47
20
27
4
22
18
36
45
23
33
32
42
34
23
9
27
17
16
29
21
12
14
5
42
33
14
24
24
33
20
36
11
1
3
48
5
14
22
13
32
14
38
38
8
Iesire:
283
----------------------
Test 7:
Intrare:
60
600
16
10
28
7
30
13
39
34
47
17
36
7
43
34
8
16
5
13
13
44
2
1
35
12
51
25
14
44
32
3
59
47
27
56
46
18
31
55
11
34
18
15
26
46
28
17
49
24
24
27
16
58
26
25
41
35
41
44
6
31
15
33
44
45
43
13
41
57
51
37
39
39
11
1
9
29
41
14
53
37
44
44
15
49
14
1
24
56
34
8
60
33
28
20
51
2
21
15
56
34
30
8
25
28
5
44
57
9
12
17
7
37
59
29
45
54
54
11
48
23
30
42
42
32
15
34
32
35
25
11
23
23
58
49
43
7
56
54
41
51
48
25
40
4
50
58
27
35
27
48
49
32
49
50
37
25
40
30
22
16
43
54
3
19
16
39
41
10
54
20
50
53
19
39
5
35
45
16
10
51
24
22
17
24
6
17
48
22
48
28
22
55
49
11
5
1
55
8
22
38
28
12
31
44
37
6
18
45
55
20
53
27
48
58
56
30
10
5
57
42
46
52
55
22
5
37
47
48
58
24
40
60
20
58
30
6
34
57
39
3
19
52
42
50
11
14
22
45
7
40
25
59
41
9
47
19
35
35
35
43
59
8
24
10
30
26
12
53
1
29
51
59
42
29
53
8
38
23
6
35
20
43
8
57
41
55
8
30
14
21
2
30
3
35
16
31
13
45
39
11
53
3
1
59
33
35
50
10
44
15
32
50
27
18
45
35
55
47
31
33
39
58
53
36
45
36
51
53
59
22
32
20
4
3
39
24
9
22
4
31
36
11
56
47
22
48
31
1
34
27
53
4
14
21
57
9
12
36
39
33
36
4
11
49
30
60
38
35
32
56
15
24
50
10
29
14
14
54
20
38
48
44
35
38
9
13
15
1
2
36
1
14
7
59
34
21
7
29
15
49
31
8
14
48
34
44
16
23
30
39
44
58
49
30
19
45
21
6
55
45
22
10
13
9
51
33
18
51
53
10
10
20
39
42
56
20
27
60
13
52
52
24
53
49
51
41
14
53
32
24
13
36
52
27
25
55
22
34
37
27
46
46
28
21
17
12
28
23
39
39
12
50
16
51
37
9
6
19
49
27
10
20
35
31
43
12
39
38
31
6
25
27
45
7
36
58
30
58
5
60
51
58
57
51
58
60
24
7
51
31
58
50
29
54
34
11
36
43
51
51
25
37
14
24
51
7
23
19
10
13
8
58
14
48
6
56
26
12
19
7
20
27
60
20
28
60
51
57
42
53
51
34
26
51
13
60
4
43
5
27
56
60
9
43
31
35
10
34
27
9
7
44
50
24
34
14
53
19
18
54
46
10
22
14
13
54
12
13
27
59
19
21
11
8
48
27
56
18
33
40
Iesire:
357
--------------------
Test 8:
Intrare:
70
700
1
57
13
51
46
47
52
54
19
25
61
56
70
45
69
54
47
12
45
11
4
3
7
69
5
23
61
2
16
40
40
44
31
38
37
8
6
50
1
10
65
35
49
8
12
63
16
37
68
30
42
12
65
6
59
19
38
7
21
3
45
38
29
19
19
69
58
4
32
70
14
33
63
62
3
2
39
12
33
22
40
51
59
56
12
30
23
5
19
54
12
52
67
67
11
64
23
10
27
67
9
9
40
59
2
38
20
30
64
15
70
28
11
32
51
55
62
28
54
14
50
37
50
9
32
9
55
20
50
21
9
30
30
51
52
22
63
21
70
62
38
28
68
35
49
26
19
6
11
32
50
29
9
25
20
63
67
67
10
40
54
9
47
17
52
37
53
61
61
57
59
49
19
46
31
56
31
35
9
59
9
9
11
32
33
7
28
29
54
65
1
30
8
41
14
30
32
25
70
33
4
41
45
60
29
35
27
63
62
18
42
28
67
69
32
69
36
27
47
55
51
6
1
68
44
67
43
11
67
6
22
70
25
65
26
4
57
3
44
64
56
23
43
23
55
51
25
45
54
50
64
57
14
5
49
51
33
62
29
61
48
48
60
24
30
68
9
48
59
65
62
24
15
53
53
27
56
7
70
1
37
27
2
69
2
6
34
51
4
23
51
12
4
13
18
20
47
50
12
60
25
29
57
12
30
65
16
37
13
65
64
44
59
38
7
35
43
64
49
30
5
39
26
61
38
51
32
41
21
66
60
25
53
24
63
60
1
37
64
65
10
9
1
68
37
11
23
19
59
66
37
51
32
13
52
68
41
35
58
69
16
21
51
49
67
7
38
20
55
41
21
67
64
48
45
34
13
1
4
63
10
7
7
1
30
11
66
51
47
54
11
9
15
16
32
7
26
48
4
56
59
31
36
13
51
47
34
40
10
52
54
49
31
63
27
8
31
52
46
38
20
63
39
45
50
2
60
32
66
46
43
14
39
56
24
28
58
15
44
40
36
56
7
48
12
33
19
19
20
36
18
3
68
23
42
8
68
56
60
28
7
10
21
50
38
45
15
39
35
39
40
55
14
31
57
40
21
33
37
17
65
30
49
4
16
39
14
4
1
35
38
17
59
61
5
5
49
23
14
60
1
68
13
34
59
55
58
55
21
11
56
13
47
49
46
44
43
12
47
67
44
62
12
1
45
10
55
29
13
35
68
47
47
61
51
60
58
54
13
31
13
27
47
52
3
66
26
70
47
60
52
17
24
40
6
30
35
58
13
26
30
13
63
42
56
48
61
4
26
12
5
26
30
38
39
70
59
3
54
41
69
25
36
21
32
68
57
64
65
26
64
69
7
47
66
29
51
68
46
16
27
39
58
7
5
45
55
35
12
17
29
4
10
33
32
34
6
25
69
42
67
57
35
54
12
44
52
10
57
22
37
28
42
25
64
61
46
16
43
16
23
7
34
17
53
9
34
6
2
55
30
23
10
53
25
50
61
2
40
67
27
30
22
44
33
57
67
42
17
34
9
45
67
37
57
13
31
20
59
23
65
14
3
45
38
28
57
16
46
12
22
19
60
5
15
61
18
1
49
66
Iesire:
412
--------------------------
test 9
Intrare:
80
800
30
8
27
51
71
57
70
13
66
2
18
35
11
25
73
61
58
39
3
15
25
56
41
54
49
7
69
3
76
68
3
20
13
33
11
44
23
18
65
49
46
37
53
45
63
57
20
52
64
30
11
74
66
47
30
78
4
32
19
3
27
4
80
44
17
22
25
16
43
76
28
15
28
66
50
64
65
62
33
76
29
79
8
17
41
8
58
16
49
3
61
54
75
15
61
47
49
13
45
68
25
5
72
61
67
32
74
16
68
59
72
1
44
66
63
24
71
69
2
45
59
4
15
61
4
52
52
66
1
9
34
16
42
10
39
32
59
45
65
64
28
52
26
70
80
76
78
68
63
66
30
36
70
49
56
1
61
52
9
33
46
59
29
33
32
78
65
30
60
60
71
44
41
32
40
25
68
3
24
3
22
22
42
41
39
77
70
11
73
17
60
18
75
19
59
9
31
65
15
11
51
39
13
29
25
54
25
62
64
24
25
35
58
64
70
45
7
33
51
62
6
20
23
63
23
31
62
30
17
13
45
30
9
32
3
10
37
2
67
34
2
45
36
7
57
26
37
50
14
29
29
42
50
34
49
32
27
42
50
57
70
68
43
78
76
13
25
52
38
66
20
11
18
18
2
41
11
10
75
74
20
22
61
74
56
23
60
1
22
47
22
9
51
5
29
80
75
42
12
58
50
20
74
38
49
19
22
52
11
63
49
72
69
56
78
40
15
15
68
23
67
7
54
79
1
24
74
59
68
27
11
5
73
26
24
56
75
12
23
72
10
17
36
15
45
23
41
56
61
25
17
49
21
9
47
19
64
31
58
54
40
40
19
29
12
73
3
64
36
7
6
11
61
53
4
49
73
57
22
74
67
54
22
5
26
24
59
16
4
39
76
41
58
3
63
21
71
53
69
36
72
61
41
54
80
55
50
18
40
62
46
44
49
9
50
33
22
74
55
52
8
7
31
10
28
80
43
28
38
9
56
3
46
35
30
21
2
17
6
22
73
27
8
71
4
24
78
12
72
63
74
68
42
79
39
50
19
44
50
13
78
46
46
50
22
79
28
11
27
35
71
16
61
27
73
16
69
59
16
37
43
24
64
38
14
27
27
24
20
74
46
16
21
17
54
2
25
68
78
77
52
75
18
53
56
64
40
59
45
59
24
18
78
33
46
55
14
50
53
53
23
33
24
73
76
2
26
57
41
2
57
70
77
48
72
41
28
65
57
51
30
37
33
4
44
56
32
7
73
49
65
33
20
33
8
57
35
65
80
71
18
10
73
34
45
50
26
64
30
45
65
5
28
71
66
17
11
24
24
58
3
37
66
37
3
30
54
75
70
19
23
36
24
24
63
54
78
44
48
63
36
24
34
6
21
67
76
58
6
72
17
8
37
48
25
73
49
69
9
73
14
62
75
79
9
25
37
7
79
21
34
75
22
28
47
58
52
75
30
22
22
65
75
16
29
66
47
7
71
39
71
71
2
57
67
66
45
39
77
50
54
75
13
74
44
10
58
79
69
53
63
23
9
71
17
33
16
20
46
40
69
75
70
6
71
15
1
75
4
59
14
52
29
10
65
48
79
9
52
65
77
23
4
68
41
46
48
50
54
24
67
71
40
80
26
53
77
13
51
5
40
42
73
2
52
52
2
5
28
70
46
8
64
77
11
63
72
72
50
12
62
61
47
12
64
43
72
61
20
34
80
48
28
75
67
4
32
57
5
46
30
5
6
54
80
50
15
49
18
37
51
60
58
57
55
34
62
37
50
35
39
47
46
54
44
48
43
36
58
64
69
49
67
32
13
29
74
3
36
43
Iesire:
476
---------------------------
